export const ROLES_MENU = {
	/**
	 * 未绑定企业状态菜单（状态码：50001）
	 * 当用户通过OAuth认证但未绑定企业时显示此菜单
	 * 只显示两个功能：
	 * 1. 绑定企业 - 引导用户完成企业绑定
	 * 2. 法律法规 - 公开访问，无需登录即可查看
	 */
	unbound: [
		{
			id: '0',
			name: '绑定企业',
			sort: 1,
			color: '#33CCFF',
			router: '/company/bound',
			iconClass: 'icon-0',
		},
		{
			id: '7',
			name: '政策法规',
			sort: 2,
			color: '#FF6633',
			target: 'self',
			router: '/regulation/list',
			iconClass: 'icon-13',
		},
	],
	enterprise: {
		defaut: [
			{
				id: '1',
				name: '基础信息',
				sort: 1,
				color: '#33CCFF',
				router: '/company/info',
				iconClass: 'icon-0',
			},
			{
				id: '2',
				name: '设施点检',
				sort: 3,
				color: '#33CCFF',
				router: '/facility/check',
				iconClass: 'icon-13',
			},
			{
				id: '3',
				name: '问题整改',
				sort: 4,
				color: '#FFCC33',
				router: '/problem/list',
				iconClass: 'icon-6',
			},
			{
				id: '4',
				name: '上报事项',
				sort: 5,
				color: '#FF6633',
				router: '/report',
				iconClass: 'icon-7',
			},
			{
				id: '5',
				name: '通知公告',
				sort: 6,
				color: '#FF6633',
				router: '/notice/list',
				iconClass: 'icon-2',
			},
			{
				id: '6',
				name: '数据汇总',
				sort: 7,
				color: '#FF6633',
				router: '/data/summary',
				iconClass: 'icon-9',
			},
			{
				id: '7',
				name: '政策法规',
				sort: 8,
				color: '#FF6633',
				target: 'self',
				router: '/regulation/list',
				iconClass: 'icon-13',
			},
		],
		// 区镇企业管理人员
		district: [
			{
				id: '3',
				name: '核查反馈',
				sort: 4,
				color: '#FFCC33',
				router: '/problem/list',
				iconClass: 'icon-6',
			},
			{
				id: '5',
				name: '通知公告',
				sort: 6,
				color: '#FF6633',
				router: '/notice/list',
				iconClass: 'icon-2',
			},
		],
	},
	government: {
		defaut: [],
		auth: {
			'XCX-PTYH': [
				{
					sort: 1,
					name: '问题整改',
					color: '#FFCC33',
					router: '/data/summary?active=问题整改',
					iconClass: 'icon-6',
				},
				{
					sort: 2,
					name: '上报事项',
					color: '#FF6633',
					router: '/data/summary?active=上报事项',
					iconClass: 'icon-7',
				},
				{
					sort: 3,
					name: '任务溯往',
					color: '#FF6633',
					router: '/data/summary',
					iconClass: 'icon-9',
				},
				{
					sort: 4,
					name: '通知公告',
					color: '#FF6633',
					router: '/notice/list',
					iconClass: 'icon-2',
				},
				{
					id: '7',
					name: '政策法规',
					sort: 5,
					color: '#FF6633',
					target: 'self',
					router: '/regulation/list',
					iconClass: 'icon-13',
				},
			],
			'XCX-LD': [
				{
					sort: 9,
					name: '数据分析',
					color: '#FF6633',
					router: '/data/analysis',
					iconClass: 'icon-5',
				},
			],
			'XCX-YJZY': [
				{
					sort: 5,
					name: '应急预案',
					color: '#FF6633',
					router: '/emergency/plan',
					iconClass: 'icon-10',
				},
				{
					sort: 7,
					name: '应急专家',
					color: '#FF6633',
					router: '/emergency/expert',
					iconClass: 'icon-11',
				},
			],
		},
		getMenuByRoles: function (roles) {
			console.log('-----roles', roles)
			let menu = this.defaut
			if (roles && Array.isArray(roles)) {
				roles.forEach((item) => {
					let roleMenu = this.auth[item]
					if (roleMenu) {
						menu = [...menu, ...roleMenu]
					}
				})
			}

			// 去重排序
			const map = new Map()
			menu = menu.filter((item) => !map.has(item.name) && map.set(item.name, 1)).sort((a, b) => a.sort - b.sort)

			console.log(menu)
			return menu
		},
	},
}
